/**
 *
 * © Bahadir Zeren 2011
 * bzeren@gmail.com
 * No warranties, express or implied, are made for this program.
 *
 */

package org.baatar.remoting.message;

import org.baatar.net.message.IResponse;

/**
 * Response message class is used to encapsulate the data to be received from 
 * the TCP service which has been connected to.
 * Instances of this serializable class are read from ObjectInputStream and 
 * sent via java.net.Socket.
 * 
 * @author b_zeren
 */
public class RemoteResponse<T> implements IResponse<T> {

    private T result = null;
    private Exception exception = null;

    /**
     * Generates a Response object without any parameter.
     * 
     * @return Response generated Response instance.
     */
    public RemoteResponse() {
    }

    /**
     * Generates a Response object with the passed parameter.
     * 
     * @param param parameter to be sent to Client.
     * 
     * @return Response generated Response instance.
     */
    public RemoteResponse(T param) {
        this.result = param;
    }

    /**
     * Generates a Response object with the exception.
     * 
     * @param ex exception information to be sent to Client.
     * 
     * @return Response generated Response instance.
     */
    public RemoteResponse(Exception ex) {
        this.exception = ex;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public T getResult() {
        return result;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Exception getException() {
        return exception;
    }

}
